local ma__fukuang = fk.CreateSkill{
  name = "ma__fukuang",
}

Fk:loadTranslationTable{
  ["ma__fukuang"] = "扶匡",
  ["@ma__fukuang"] = "扶匡",
  [":ma__fukuang"] = "每轮限一次，你可以重置至多三名已横置角色，视为使用一张结算等量次的【杀】或【桃】。",

  ["#ma__fukuang"] = "扶匡：重置一至三名角色，视为使用【杀】或【桃】（先选择使用的牌名和目标，然后选择重置目标）",

  ["$ma__fukuang1"] = "",
  ["$ma__fukuang2"] = "",
}

ma__fukuang:addEffect("viewas", {
  pattern = "slash,peach",
  anim_type = "defensive",
  interaction = function(self, player)
    local all_names = {"slash", "peach"}
    local names = player:getViewAsCardNames(ma__fukuang.name, all_names, nil, player:getTableMark("ma__fukuang-turn"))
    return UI.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if self.interaction.data == nil then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = ma__fukuang.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p)
      return p.chained
    end)
    if #targets == 0 then return " " end
    targets = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 3,
      targets = targets,
      skill_name = ma__fukuang.name,
      prompt = "#ma__fukuang",
      cancelable = false,
    })
    for _, p in ipairs(targets) do
      p:setChainState(false)
    end
    if #targets > 0 then
      use.additionalEffect = (use.additionalEffect or 0) + #targets-1
    end
  end,

  enabled_at_play = function(self, player)
    return player:usedSkillTimes(ma__fukuang.name, Player.HistoryRound) == 0 and
      table.find(Fk:currentRoom().alive_players, function(p)
        return p.chained
      end)
  end,
  enabled_at_response = function(self, player, response)
    return not response and
      player:usedSkillTimes(ma__fukuang.name, Player.HistoryRound) == 0 and
      table.find(Fk:currentRoom().alive_players, function(p)
        return p.chained
      end)
  end,
})

return ma__fukuang
